package io.renren.modules.app.controller;


import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.UserFavor;
import io.renren.modules.app.service.UserFavorService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 用户点赞表
 *
 * @author chenjiacheng
 * @email 
 * @date 2019-02-11 19:04:20
 */
@RestController
@RequestMapping("app/userfavor")
public class UserFavorController {
    @Autowired
    private UserFavorService userFavorService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("app:userfavor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userFavorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userId}")
    @RequiresPermissions("app:userfavor:info")
    public R info(@PathVariable("userId") Integer userId){
			UserFavor userFavor = userFavorService.selectById(userId);

        return R.ok().put("userFavor", userFavor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("app:userfavor:save")
    public R save(@RequestBody UserFavor userFavor){
			userFavorService.insert(userFavor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("app:userfavor:update")
    public R update(@RequestBody UserFavor userFavor){
			userFavorService.updateById(userFavor);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("app:userfavor:delete")
    public R delete(@RequestBody Integer[] userIds){
			userFavorService.deleteBatchIds(Arrays.asList(userIds));

        return R.ok();
    }

}
